extends RigidBody2D
class_name RDemo

# 1 超右 -1 超左
var knightFace : int = 1; 

var x:float = 300;
var y:float = 100;
# 速度标量
var speed = 200;
# 速度向量
var velocity = Vector2(1,1);

func _init():
	# 创建碰撞体
	self.position = Vector2(x,y)

	# 外观
	var knight = Sprite.new();
	knight.texture = load("res://icon.png")

	self.add_child(knight);

	# 实际大小
	var h = knight.texture.get_height() / 2;
	var w = knight.texture.get_width() / 2;

	# 碰撞盒
	var rect = RectangleShape2D.new();
	rect.extents = Vector2(w,h);
	var oid = self.create_shape_owner(self);
	self.shape_owner_add_shape(oid,rect);
	print("radius",rect.extents);
	
	
